package com.lihui.poker;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2022/09/27  18:58
 */
public class Poker {
    private String suit;
    private  int rank;
    private static final String[] suits = {"♠","♥","♦","♣"};

    public Poker(String suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }
    public Poker() {
    }

    public String getSuit() {
        return suit;
    }

    public int getRank() {
        return rank;
    }

    public void setSuit(String suit) {
        this.suit = suit;
    }

    public void setRank(int rank) {
        this.rank = rank;
    }

    public static List<Poker> buyOne(){
        List<Poker> pokers = new ArrayList<>() ;
        for (int i = 0; i < suits.length; i++) {
            for (int j = 1; j <= 13 ; j++) {
               String suitsTemp = suits[i];
               Poker poker = new Poker(suitsTemp,j);
               pokers.add(poker);
            }
        }
        return pokers;
    }
    public static void shuffle(List<Poker> pokers){
        if (pokers == null){
            throw new RuntimeException("不能为空");
        }
        Random random = new Random();
        for (int i = 0; i < pokers.size(); i++) {
            int index= random.nextInt(pokers.size());
            Poker temp = pokers.get(index);
            pokers.set(index, pokers.get(i));
            pokers.set(i,temp);

        }

    }
    public static List<List<Poker>> toDoing(List<Poker> pokers){
        List<List<Poker>> players = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            List<Poker> player = new ArrayList<>();
            players.add(player);
        }
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < players.size(); j++) {
                List<Poker> player = players.get(j);
                Poker poker = pokers.remove(0);
                player.add(poker);
            }
        }
        return players;
    }
    @Override
    public String toString() {
        return "[" + suit + " " + rank + "]";
    }
}
